<template>
  <div class="staCompreWrap">
  
    <NavBar :title="'灾情管理列表'" :text="'返回'" :cityName="''" ></NavBar>
    <div class="titleArea">
      <div class="top">
        <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          @load="onLoad"
        >
          <van-cell
            v-for="(item, index) in list"
            :key="index"
            @click="getlistclick(item, index)"
          >
            <van-radio-group v-model="radio" direction="horizontal">
              <div class="allbaogao">
                <van-radio :name="item"></van-radio>
                <div class="leftbaogao">
                  {{ item.itemdisasterType }}{{ item.disasterType }} 灾情报告
                </div>
                <div class="rightbaogao">{{ item.uploadTime }}</div>
              </div>
            </van-radio-group>
          </van-cell>
        </van-list>
      </div>
      <div class="bottomnutton">
        <van-button @click="dc" block>导出报告</van-button>
      </div>
    </div>
  </div>
</template>
<script type="text/javascript">
import disastersituationApi from '@/service/disastersituation.js'
import Vue from 'vue'
import { List, Cell, Form, Field } from 'vant'

Vue.use(Field)
Vue.use(List)
Vue.use(Cell)

export default {
  data() {
    return {
      list: [],
      indexclick: '',
      citysss: '',
      radio: 0,
      loading: false,
      finished: false,
      page: {
        page: 1,
        limit: 15,
      },
    }
  },
  created() {
    // this.getlist()
    this.citysss = this.$store.getters.location[1].name
  },
  mounted() {
    this.getlist()
    this.indexclick = 0

    this.radio = 0
    this.citysss = this.$store.getters.location[1].name
  },
  watch: {},

  methods: {
    getlistclick(item, index) {
      this.indexclick = index
      this.radio = item
    },
    getlist() {
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      disastersituationApi
        .Getdisastersituation({
          userId: this.$store.getters.userid,
          page: this.page.page,
          limit: this.page.limit,
        })
        .then((res) => {
          if (res.data.length === 0) {
            // 判断获取数据条数若等于0
            this.list = [] // 清空数组
            // this.radio = this.list[0]
            this.finished = true // 停止加载

            // 数据全部加载完成
          } else {
            this.list=res.data
            this.list = this.list.flat(Infinity)

            var list1 = []
            this.radio = this.list[0]
            // if (this.list.length >= res.total) {
            //   this.finished = true
            // } else {
            //   this.loading = false
            // }
            this.list.forEach((it) => {
              var s = it.disasterType.includes(this.$route.query.text)

              if (s == true) {
                list1.push(it)
              }
            })
            this.list = list1
            this.finished = true
          }
        })
        .catch((error) => {
          console.log(error)
        })

      // 加载状态结束
      this.loading = false
    },
    onLoad() {
      let timer = setTimeout(() => {
        // 定时器仅针对本地数据渲染动画效果,项目中axios请求不需要定时器
        this.getlist() // 调用上面方法,请求数据
        this.page.page++ // 分页数加一
        this.finished && clearTimeout(timer) //清除计时器
      }, 100)
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
    },
    dc() {
      window.location.href = `http://121.52.212.68:9092/itg/dlqxfw/operdecision/disaster/report?id=${this.radio.id}`

      this.$toast({
        message: '导出成功！',
        position: 'center',
      })
    },
    onClickLeft() {
      this.$router.go(-1)
    },
    onClickRight() {
      if (this.tabActive == 1) {
        this.$toast('此菜单下，请点击地图！')
        return
      }
      this.showComCity = true
    },
  },
}
</script>
<style type="text/css" lang="less" scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-size: 12px;
  color: #fff;
}

/deep/ .van-field__control--custom {
  height: 34px !important;
  background-color: #93c0fe;
  margin-bottom: 18px;
  border-radius: 10px;
}
.radioactive {
  background-color: #004ce9 !important;
}
/deep/ .van-cell .van-icon {
  border-color: #fff;
  opacity: 0.5;
  border: 1px solid #656b75;
}
.rights {
  color: #fff;
}

/deep/ .van-field__body {
  background-color: #548bf6;
}
/deep/ .van-uploader__preview-image {
  margin-top: 10px;
}

/deep/ .van-uploader__upload {
  background-color: transparent;
  border: 1px solid #d2d2d2;
  margin-top: 15px;
}

/deep/ .van-cell {
  display: flex;
  align-items: center;

  height: 40px;
  background: #ffffff;
  box-shadow: 0px 0px 15px 0px rgba(222, 222, 222, 0.36);
  border-radius: 10px;
  margin-bottom: 16px;
}
/deep/ .van-list__finished-text {
  color: #656b75;
}
.active {
  background-color: blue;
}

.actives {
  background-color: #d2d2d2;
}

/deep/ .van-field__label {
  width: 70px;
  margin-left: 5px;
}

body,
html {
  background-image: url('../assets/topBg.png');
  background-repeat: no-repeat;
  background-size: cover;
}
#ditudist {
  width: 100%;
  position: absolute;
  top: 630px;
  // bottom: 0;

  height: 240px;
  background: url('../assets/dtwgn.png') center no-repeat;
  background-size: cover;
}
.rightbaogao {
  float: right;
  font-size: 12px;

  font-weight: 400;
  color: #656b75;
}
// /deep/  .van-radio__icon{
//     opacity: 0.5;
// border: 1px solid #656B75;
// border-radius: 50%;
// }
.leftbaogao {
  float: left !important;
  font-size: 14px;
  width: 50%;
  font-weight: 500;
  color: #101010;
}
/deep/ .van-radio-group--horizontal {
  display: flex;

  padding-left: 8px;
  padding-right: 8px;
  width: 100%;
}
.allbaogao {
  float: right;
  display: flex;
  justify-content: space-between;
  text-align: left;
  padding-left: 8px;

  width: 100%;
}
// /deep/ .van-radio__label {
//   color: #fff;
// }
/deep/ .van-nav-bar__content {
  font-size: 28px;
  background-color: rgba(53, 124, 255, 1);
}
.bottomConditudist {
  // background-color: rgb(172, 163, 163);
  text-align: center;
  position: absolute;
  // z-index: 9999;
  color: #fff;
  bottom: 20px;
  width: 100%;
  font-size: 16px;

  // margin-bottom: 30px;
}
.box2 {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #d2d2d2;
  display: table-cell;
  vertical-align: middle;
  text-align: center;
  padding: 5px;
}

.active {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #4853ea;
  display: table-cell;
  vertical-align: middle;
  text-align: center;
  padding: 5px;
}

.staCompreWrap {
  .pageCover();
  overflow-y: auto;
  background-color: rgba(249, 250, 253, 1);
  background-repeat: no-repeat;
  background-size: cover;
  overflow-x: hidden;

  .btnArea {
    margin: 10px;
    background: white;
    border-radius: 10px;
    padding: 10px;
    box-sizing: border-box;

    .btnLine {
      margin-bottom: 10px;
    }

    .btnLine:last-child {
      margin-bottom: 0px;
    }

    .btnLineSmall {
      margin-right: 10px;
    }
  }

  .titleArea {
    position: relative;
    left: 9px;
    top: 0;
    width: 100%;
    height: 100%;

    img {
      width: 95%;
      background-size: cover;
    }

    .bottomnutton {
      left: 50%;
      transform: translate(-50%, -50%);
      position: absolute;
      //   top: 550px;
      bottom: 50px;
      border-radius: 40px;
      /deep/ .van-button {
        width: 270px;
        height: 40px;
        font-size: 15px;
        background: #357cff;
        border-radius: 20px;
      }
    }

    /deep/ .van-button {
      width: 100px;
      height: 30px;
      margin: auto;
    }

    .top {
      position: absolute;
      overflow-y: auto;
      top: 20px;
      //   background-color: #548bf6;
      width: 95%;
      border-radius: 10px;
      height: 75%;
      padding: 7px;
      color: #fff;
      input {
        border: transparent;

        width: 100%;
        /* border: 1px solid; */
        border-bottom: 1px solid;
      }
    }

    .box {
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-right: 22px;
      margin-bottom: 10px;
    }

    .box1 {
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-left: -2px;
      margin-right: 18px;
      margin-bottom: 10px;
    }

    p {
      font-size: 12px;

      span {
        color: #d2d2d2;
      }
    }

    .left {
      height: 210px;
      line-height: 240px;
      font-size: 15px;
      float: left;
      width: 25%;

      //   background-color: #1989fa;
    }

    .right {
      float: left;
      padding-top: 6px;
      width: 75%;
      height: 210px;
    }

    .titleCon {
      position: absolute;
      top: 6px;
      .px2rem(left, 25px);
      color: white;
      font-size: 16px;
      font-weight: bold;
    }

    .staDistime {
      position: absolute;
      left: 35px;
      .px2rem(top, 50px);
      color: white;
    }
  }

  .listArea {
    position: absolute;
    left: 10px;
    right: 10.3px;
    top: 140px;
    bottom: 10%;
    overflow: scroll;
    background: white;

    .listTitle {
      overflow: hidden;
      padding: 10px 0;

      span {
        float: left;
        width: 33.33%;
        text-align: center;
      }

      span.titleFour {
        width: 25%;
      }

      .titleOne {
        width: 30%;
      }

      .titleTwo {
        width: 36.66%;
      }

      .titleLineHeightMiddle {
        line-height: 36.8px;
      }
    }

    .listTitle:first-child {
      color: #1989fa;
      font-weight: bold;
    }

    .listTitle:nth-child(2n) {
      background-color: #dcefff;
    }

    .listCon {
      padding: 10px;
      margin-bottom: 10px;
    }
  }

  .elementArea {
    position: absolute;
    left: 10px;
    right: 10px;
    top: 56px;
    height: 200px;
    background: white;
    border-radius: 10px;
    padding: 10px;
  }

  .elementListArea {
    position: absolute;
    left: 10px;
    right: 10px;
    top: 286px;
    bottom: 60px;
    background: white;
    border-radius: 10px;
    padding: 10px;
    overflow: scroll;

    .elementList {
      margin-bottom: 10px;
      padding-bottom: 10px;
      border-bottom: 1px solid #ececec;
    }

    .elementListLine {
      font-size: 14px;
      padding: 5px 0;
    }

    .elementList:last-child {
      margin-bottom: 0;
      padding-bottom: 0;
      border-bottom: none;
    }
  }

  /deep/ .van-tabs {
    margin: 10px;
  }

  /deep/ .van-tab--active {
    color: #1989fa;
  }

  /deep/ .van-tabs--line /deep/ .van-tabs__wrap {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
  }
}

.factorBg {
  position: absolute;
  left: 0;
  .px2rem(bottom, 0px);
  width: 100%;
  height: 200px;
}

.bottomCon {
  color: white;
  position: absolute;
  bottom: 3%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 14px;
}
</style>
